#include <iostream>
#include <string>
#include <memory>
#include "Command_excute.hpp"
#include "TcpServer.hpp"
#include "Log.hpp"
using std::cout;
using std::endl;

void Usage(const char *arg)
{
    cout << "USAGE:" << endl;
    cout << "#         please enter: " << arg << "serverport" << endl;
}

// ./server 8888
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        Usage(argv[0]);
        exit(USAGE_ERR);
    }
    Enablescreen();
    uint16_t port = std::stoi(argv[1]);


    CommandEx cmd("./safe.txt"); // 执行命令模块
    // 网络模块
    std::unique_ptr<TcpServer> tsp = std::make_unique<TcpServer>(port, std::bind(&CommandEx::Excute, &cmd, std::placeholders::_1));
    
    tsp->InitServer();
    tsp->StartServer();

    return 0;
}